import time
from unittest import TestCase
from ddt  import ddt,data,unpack
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from Transfer_Accounts_data import Transfer_Accounts_data
from Transfer_Accounts_Operation import Transfer_Accounts_Operation


@ddt
class Test1Transfer_Accounts(TestCase):
	@data(*Transfer_Accounts_data.transfer_accounts_data)
	@unpack
	def testtransfer_accounts1(self,payee_name,payee_account,Receiving_bank,pay_money,pay_purpose,transfer_method, expect, case):
		url = "http://127.0.0.1:4723/wd/hub"

		param = 	{
			  "deviceName": "5EFGK18814000001",             # 设备序列号  -->  adb  devices
			  "platformName": "Android",                    # 安卓系统
			  "platformVersion": "10",                      # 鸿蒙要写 11版本，或者10版本
			  "appPackage": "com.chinamworld.main",         # adb  shell  pm list package  找到你的要测的包名称
			  "appActivity": "com.ccb.start.MainActivity",  #  aapt   d  badging  g:\sina.apk  -->lunachable-activity
			  "noReset": True,                              # 启动时不重置软件
			  "skipServerInstallation": True,               # 解决手机重复安装appium连接的软件
			  "automationName": "UiAutomator1"              # app权限自动获取
			}

		driver = webdriver.Remote(url,param)
		time.sleep(15)
		# 广告弹窗点击关闭
		try:
			el1 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"关闭")
			el1.click()
			time.sleep(4)
		except:
			time.sleep(4)
		# 建行转账
		TA = Transfer_Accounts_Operation()
		result = TA.transfer_accounts(driver,payee_name,payee_account,Receiving_bank,pay_money,pay_purpose,transfer_method)

		if expect == result:
			print("通过")
		else:
			driver.save_screenshot(f'D:/Users/北极星的眼泪/Desktop/demo/APP自动化测试第二天/报错截图/{case}.png')
		# 退出
		driver.quit()

		self.assertEqual(expect, result)